package cn.edu.fzu.homemaking.company.service.impl;

import cn.edu.fzu.homemaking.company.domain.entity.RobotMsg;
import cn.edu.fzu.homemaking.company.domain.enums.RobotMsgStatusEnum;
import cn.edu.fzu.homemaking.company.mapper.RobotMsgMapper;
import cn.edu.fzu.homemaking.company.service.RobotMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wanjie
 * @version 1.0
 */
@Service
public class RobotMsgServiceImpl implements RobotMsgService {
    @Resource
    private RobotMsgMapper robotMsgMapper;

    @Override
    public List<RobotMsg> queryAllRobotMsgs(Long companyId, String key, String message, RobotMsgStatusEnum status) {
        return robotMsgMapper.queryAllRobotMsgs(companyId, key, message, status);
    }

    @Override
    public void insertRobotMsg(String key, String message, RobotMsgStatusEnum status, Long companyId) {
        RobotMsg robotMsg = new RobotMsg();
        robotMsg.setKey(key);
        robotMsg.setMessage(message);
        robotMsg.setStatus(status);
        robotMsg.setCompanyId(companyId);
        robotMsgMapper.insertRobotMsg(robotMsg);
    }

    @Override
    public void updateRobotMsg(Long id, String key, String message, RobotMsgStatusEnum status, Long companyId) {
        RobotMsg robotMsg = new RobotMsg();
        robotMsg.setId(id);
        robotMsg.setKey(key);
        robotMsg.setMessage(message);
        robotMsg.setStatus(status);
        robotMsg.setCompanyId(companyId);
        robotMsgMapper.updateRobotMsg(robotMsg);
    }

    @Override
    public void deleteRobotMsg(Long id, Long companyId) {
        robotMsgMapper.deleteRobotMsg(id, companyId);
    }
}
